package org.fujay.langchain4jserver.domain.model.vo;

import lombok.Builder;

import java.io.Serial;
import java.io.Serializable;

/**
 * 模型配置值对象
 *
 * @param timeOut
 * @param maxMemory
 * @param responseFormat 0: text, 1: json
 */
@Builder
public record ModelConfig(
        String baseUrl,
        String apiKey,
        String secretKey,
        Double temperature,
        Integer topK,
        Double topP,
        Integer maxTokens,
        Integer numCtx,
        Integer timeOut,
        Integer maxRetries,
        Integer maxMemory,
        Boolean logRequests,
        Boolean logResponses,
        Integer responseFormat)
        implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    public ModelConfig(
            String baseUrl,
            String apiKey,
            String secretKey,
            Double temperature,
            Integer topK,
            Double topP,
            Integer maxTokens,
            Integer numCtx,
            Integer timeOut,
            Integer maxRetries,
            Integer maxMemory,
            Boolean logRequests,
            Boolean logResponses,
            Integer responseFormat) {
        this.baseUrl = baseUrl;
        this.apiKey = apiKey;
        this.secretKey = secretKey;
        this.temperature = temperature != null ? temperature : 0.7;
        this.topK = topK;
        this.topP = topP;
        this.maxTokens = maxTokens;
        this.numCtx = numCtx;
        this.timeOut = timeOut;
        this.maxRetries = maxRetries;
        this.maxMemory = maxMemory;
        this.logRequests = logRequests != null ? logRequests : false;
        this.logResponses = logResponses != null ? logResponses : false;
        this.responseFormat = responseFormat != null ? responseFormat : 0;
    }
}
